package programmingChallenges.chap3;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

class Main implements Runnable{
    static String ReadLn(int maxLength){  // utility function to read from stdin,
                                          // Provided by Programming-challenges, edit for style only
        byte line[] = new byte [maxLength];
        int length = 0;
        int input = -1;
        try{
            while (length < maxLength){//Read untill maxlength
                input = System.in.read();
                if ((input < 0) || (input == '\n')) break; //or untill end of line ninput
                line [length++] += input;
            }

            if ((input < 0) && (length == 0)) return null;  // eof
            return new String(line, 0, length);
        }catch (IOException e){
            return null;
        }
    }

    public static void main(String args[])  // entry point from OS
    {
        Main myWork = new Main();  // Construct the bootloader
        myWork.run();            // execute
    }

    public void run() {
        new myStuff().run();
    }
}

class myStuff implements Runnable {
    public void run() {
    	 
    	List<BigDecimal> trip = new ArrayList<BigDecimal>();
    	
    	int numOfPeople;
    	for (int k=0; k<1000; k++) {
    		String tmp = Main.ReadLn(100);
	    	numOfPeople = Integer.parseInt(tmp.replaceAll("\r", ""));
	    	
	    	if (numOfPeople == 0) {
	    		trip.add(new BigDecimal(numOfPeople));
	    		break;
	    	}
	    	
	    	trip.add(new BigDecimal(numOfPeople));
	    	String moneySpent;
	    	int dollor;
	    	int cent;
	    	BigDecimal centSpent;
	    	
	    	List<BigDecimal> tmpList = new ArrayList<BigDecimal>();
	    	
	    	
	    	
	    	for (int i=0; i<numOfPeople; i++) {
	    		moneySpent = Main.ReadLn(100).replace("\r", "");
//	    		String[] arr = moneySpent.subString(0, moneySpent.indexOf("."));
	    		
	    		dollor = Integer.parseInt(moneySpent.substring(0, moneySpent.indexOf(".")));
	    		cent   = Integer.parseInt(moneySpent.substring(moneySpent.indexOf(".")+1, moneySpent.length()));
	    		centSpent = new BigDecimal(dollor*100 + cent);
	    		trip.add(centSpent);
	    		
	    		
	    		
	    		
	    		
	    		
	    		tmpList.add(centSpent);
	    	}
	    	
	    	int sum = 0;
	    	for (int a=0; a<tmpList.size(); a++) {
	    		sum += tmpList.get(a).intValue();
	    	}
	    	double avg = Math.round(sum / numOfPeople);
	    	System.out.println(avg);
	    	
	    	int sumDiff = 0;
	    	for (int p=0; p<tmpList.size(); p++) {
	    		int i = tmpList.get(p).intValue();
	    		if (i > avg) {
	    			sumDiff = i - avg;
	    		}
	    	}
    	}
    	
    	for (int g=0; g<trip.size(); g++) {
    		System.out.println(trip.get(g));
    	}
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    	
    }
}